package com.cqtczh.qhd.driver.acticity.carteam;

import java.util.List;

import tools.L;

import javabeen.CarTeamIdBeen;

import adapter.CarTeamMemberListAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

import com.cqtczh.qhd.driver.R;
import com.cqtczh.qhd.driver.acticity.base.BaseActivity;
import com.cqtczh.qhd.driver.acticity.order.OrderDetails;
import com.cqtczh.qhd.driver.acticity.order.OrdersActivity;

public class CompleteCarTeamMember extends BaseActivity {
	private List<CarTeamIdBeen> member;
	
	private CarTeamMemberListAdapter adapter;
	
	
	private ListView listView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_complete_car_team_member);
		setContentView(R.layout.activity_my_car_team_member);
		ini();
	}
	
	private void ini(){
		TextView head_title=(TextView) findViewById(R.id.head_title);
		head_title.setText("公司车队成员");
		ImageView imageView=(ImageView) findViewById(R.id.head_left);
		imageView.setVisibility(View.VISIBLE);
		imageView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				CompleteCarTeamMember.this.finish();
			}
		});
		Button button =(Button) findViewById(R.id.Adddriver);
		button.setVisibility(View.GONE);
		Intent intent=getIntent();
		member=(List<CarTeamIdBeen>) intent.getSerializableExtra("carmembers");
		listView = (ListView) findViewById(R.id.carteammember);
		if (member.size()>0) {
			iniListView();
		}
	
	}
	
	
	private void iniListView(){
		
		adapter = new CarTeamMemberListAdapter(CompleteCarTeamMember.this,
				member, R.layout.activity_my_team_list_iteam_new,2);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(new OnItemClickListener() {
			// 点击查看司机的历史订单
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(CompleteCarTeamMember.this,OrdersActivity.class);
						//CarTeamMemberOrders.class);
				intent.putExtra("company", member.get(arg2)
						.getCarownerid() + "");
				intent.putExtra("company_member_name", member.get(arg2).getCarownername());
			//	intent.putExtra("CarTeamId", CAR_TEAM_ID);
				// L.v("Carteamdata.getCar_team_id()",
				// Carteamdata.getCar_team_id());
				startActivityForResult(intent, 100);
			}
		});
		
		
	}
	
}
